#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;

struct Airplanes{
	int a,b;
	inline void Reader(){
		scanf("%d%d",&a,&b);
	}
	inline bool operator<(const Airplanes&air)const{
		return a<air.a;
	}
};Airplanes A1[110000],A2[110000];

struct Cmp{
	inline bool operator()(const int&a,const int&b){
		return a>b;
	}
};
priority_queue<int,vector<int>,Cmp>Q;
int n,m1,m2,Dp1[110000],Dp2[110000];
int main(){
	freopen("airport.in","r",stdin);
	freopen("airport.out","w",stdout);
	
	scanf("%d%d%d",&n,&m1,&m2);
	
	for(int i=1;i<=m1;i++)
		A1[i].Reader();
	sort(A1+1,A1+m1+1);
	for(int j=1;j<=m2;j++)
		A2[j].Reader();
	sort(A2+1,A2+m2+1);
	
	
	for(int i=0;i<=n;i++){
		int now=0;
		while(!Q.empty())Q.pop();
		for(int j=1;j<=m1;j++){
			while(!Q.empty()&&Q.top()<A1[j].a)Q.pop(),now--;
			if(now<i){
				Dp1[i]++;now++;
				Q.push(A1[j].b);
			}
		}
	}
	
	
	for(int i=0;i<=n;i++){
		int now=0;
		while(!Q.empty())Q.pop();
		for(int j=1;j<=m2;j++){
			while(!Q.empty()&&Q.top()<A2[j].a)Q.pop(),now--;
			if(now<i){
				Dp2[i]++;now++;
				Q.push(A2[j].b);
			}
		}
	}
	
	int res=0xcfcfcfcf;
	for(int i=0;i<=n;i++)
		res=max(res,Dp1[i]+Dp2[n-i]);
	printf("%d\n",res);
	return 0;
} 
